import os

from celery import Celery


#一.环境配置
#方法一
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mail.settings")
#方法二
if not os.getenv('DJANGO_SETTINGS_MODULE'):
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mail.settings'


#二.实例化celery对象


app = Celery('celery_tasks')


#三.设置broker   让celery加载broker 的配置文件
app.config_from_object('celery_tasks.config')
#3.1elery自动检测tasks的任务
app.autodiscover_tasks(['celery_tasks.sms','celery_tasks.email'])

#四.设置worker
# celery -A celery_tasks.main worker -l info
# celery -A celery_tasks.main worker -l info